package com.yanqu.road.server.cmd.activity.apprentice;

import com.yanqu.road.exception.BusinessException;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ApprenticeProto;
import com.yanqu.road.pb.activity.SonHaiProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.apprentice.CrossApprenticeActivity;
import com.yanqu.road.server.manager.activity.apprentice.CrossApprenticeMgr;
import com.yanqu.road.server.manager.activity.sonhai.CrossSonHaiActivity;
import com.yanqu.road.server.manager.activity.sonhai.CrossSonHaiActivityMgr;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C2_APPRENTICE_DEBUG, desc = "爱徒养成-gm指令调试")
public class CrossApprenticeDebugCmd extends CrossCommand {


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        ApprenticeProto.ApprenticeDebugReqMsg reqMsg = ApprenticeProto.ApprenticeDebugReqMsg.parseFrom(packet.getBytes());
        CrossApprenticeActivity activity = CrossApprenticeMgr.getActivity(reqMsg.getActivityId());
        if (activity == null) {
            return;
        }
        try {
            activity.debug(packet.getPlayerId(), reqMsg.getCode(), reqMsg.getParam());
        } catch (BusinessException e) {
            ApprenticeProto.ApprenticeEnterActivityRespMsg.Builder respMsg = ApprenticeProto.ApprenticeEnterActivityRespMsg.newBuilder();
            respMsg.setRet(e.getCode());
            MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.U_APPRENTICE_ENTER_ACTIVITY, respMsg));
        }
    }

    @Override
    public void sendData() {

    }
}
